home *** CD-ROM | disk | FTP | other *** search
/ Champak 141 / (Vol 141) Oct 17 2011.iso / Games / dodge.swf / scripts / __Packages / Stepper.as < prev    next >
Encoding:
Text File  |  2011-10-17  |  1.5 KB  |  70 lines

  1. class Stepper
  2. {
  3.    static var removalStack;
  4.    static var steppables = new ObjectList(true);
  5.    static var paused = false;
  6.    function Stepper()
  7.    {
  8.    }
  9.    static function add(s)
  10.    {
  11.       Stepper.steppables.add(s);
  12.    }
  13.    static function remove(s)
  14.    {
  15.       Stepper.addToRemoveStack(s);
  16.    }
  17.    function stepAll()
  18.    {
  19.       if(!Stepper.paused)
  20.       {
  21.          this.removeAllFromStack();
  22.          var _loc2_ = 0;
  23.          while(_loc2_ < Stepper.steppables.getLength())
  24.          {
  25.             Steppable(Stepper.steppables["get"](_loc2_)).step();
  26.             _loc2_ = _loc2_ + 1;
  27.          }
  28.       }
  29.    }
  30.    static function addToRemoveStack(o)
  31.    {
  32.       if(Stepper.removalStack == null)
  33.       {
  34.          Stepper.removalStack = new Array();
  35.       }
  36.       Stepper.removalStack.push(o);
  37.    }
  38.    function removeAllFromStack()
  39.    {
  40.       var _loc1_ = 0;
  41.       while(_loc1_ < Stepper.removalStack.length)
  42.       {
  43.          Stepper.steppables.remove(Stepper.removalStack[_loc1_]);
  44.          _loc1_ = _loc1_ + 1;
  45.       }
  46.       Stepper.removalStack = null;
  47.    }
  48.    static function pause()
  49.    {
  50.       Stepper.paused = true;
  51.    }
  52.    static function unpause()
  53.    {
  54.       Stepper.paused = false;
  55.    }
  56.    static function isPaused()
  57.    {
  58.       return Stepper.paused;
  59.    }
  60.    function killAll()
  61.    {
  62.       var _loc1_ = 0;
  63.       while(_loc1_ < Stepper.steppables.size())
  64.       {
  65.          Stepper.addToRemoveStack(Stepper.steppables["get"](_loc1_));
  66.          _loc1_ = _loc1_ + 1;
  67.       }
  68.    }
  69. }
  70.